﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AAA.Meta.Trade;
using AAA.Meta.Trade.Data;

namespace AAA.Trade
{
    public abstract class AbstractTrade : ITrade
    {
        #region ITrade Members
        private TradeModeEnum _tradeMode;
        private List<AAA.Logger.Logger> _lstTradeLogger;
        protected AccountInfo _accountInfo;
        private bool _isAutoReconnect;

        public bool IsAutoReconnect
        {
            get { return _isAutoReconnect; }
            set { _isAutoReconnect = value; }
        }

        public AccountInfo AccountInfo
        {
            get { return _accountInfo; }
        }

        public AbstractTrade()
        {
            _lstTradeLogger = new List<AAA.Logger.Logger>();
        }

        public TradeModeEnum TradeMode 
        { 
            get
            {
                return _tradeMode;
            }
            set
            {
                _tradeMode = value;
            }
        }
                
        public void AddTradeLogger(AAA.Logger.Logger logger)
        {
            if (_lstTradeLogger.Contains(logger))
                return;
            _lstTradeLogger.Add(logger);
        }

        public void RemoveTradeLogger(AAA.Logger.Logger logger)
        {
            _lstTradeLogger.Remove(logger);
        }

        protected List<AAA.Logger.Logger> Loggers
        {
            get
            {
                return _lstTradeLogger;
            }
        }

        public abstract void OnMessage(AAA.Meta.Trade.MessageEvent messageEvent);
        public abstract object InitProgram(AAA.Meta.Trade.Data.AccountInfo accountInfo);
        public abstract object CA();
        public abstract object Login();
        public abstract object Logout();
        public abstract object SendOrder(AAA.Meta.Trade.Data.OrderInfo orderInfo);
        public abstract object CancelOrder(AAA.Meta.Trade.Data.OrderInfo orderInfo);
        public abstract object ChangeQuantity(AAA.Meta.Trade.Data.OrderInfo orderInfo);
        public abstract object ChangePrice(AAA.Meta.Trade.Data.OrderInfo orderInfo);
        public abstract object GetOrderStatus(AAA.Meta.Trade.Data.OrderInfo orderInfo);
        public abstract object GetDealReport(string strStartDate, string strEndDate);
        public abstract object GetOrderReport(string strStartDate, string strEndDate);
        public abstract object GetCoverReport(string strStartDate, string strEndDate);
        public abstract object GetPositionReport();
        public abstract object GetTodayEquity();
        public abstract string QuerySymbolCode(string strSymbolType, string strStrikePrice, string strPubOrCall, string strYear, string strMonth);
        public abstract bool IsConnected();
        public abstract Dictionary<string, string> SplitMessage(string strMessage, string strMessageType);       

        #endregion
    }
}
